<?php
include ("../function.php");
include "../dbconnect.php";
?>
<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8">
    <title>IQ TEST</title>
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link rel="stylesheet" href="<?php echo $base_url;?>css/bootstrap.css" media="screen">
    <link rel="stylesheet" href="<?php echo $base_url;?>css/bootswatch.min.css">
	<link rel="stylesheet" href="<?php echo $base_url;?>css/form_validation.css">
    <!-- HTML5 shim and Respond.js IE8 support of HTML5 elements and media queries -->
    <!--[if lt IE 9]>
      <script src="<?php echo $base_url;?>js/html5shiv.js"></script>
      <script src="<?php echo $base_url;?>js/respond.min.js"></script>
    <![endif]-->
	<script src="<?php echo $base_url;?>js/jquery-1.10.2.min.js"></script>
	<script src="<?php echo $base_url;?>js/bootstrap.min.js"></script>
    <script src="<?php echo $base_url;?>js/bootswatch.js"></script>
  </head>
  <body>
<?php include ("../menu.php"); ?>
    <div class="container">  
      <!-- Forms
      ================================================== -->
      <div>
        <div class="row">
          <div class="col-lg-12">
            <div class="page-header">
              <h2 id="forms">ประวัติการทำแบบทดสอบทั้งหมด   </h2>
            </div>
          </div>
        </div>
        <div class="row">
            <div class="well bs-component">
            <div class="bs-component">
				<table class="table table-bordered table-striped table-hover ">
				
					<?php
					$sqle = "SELECT * FROM excercise  WHERE status=1";
					$resulte = mysql_query($sqle, $link);
					mysql_query("SET NAMES UTF8");
					$numrows = mysql_num_rows($resulte);
					if($numrows > 0)
					{
						echo "<thead><tr><th>User</th>";
						//echo "<th>รายชื่อ</th>";
						$num = 1;
						while ($arr = mysql_fetch_array($resulte))
						{
							echo "<th>".$arr['title']."</th>";
							echo "<th>".$arr['title']." แบบสลับข้อ</th>";
						}
						echo "</tr></thead>";
						echo "<tbody>";
						
						$sqls = "SELECT name,id_student,student_code FROM student";
						$results = mysql_query($sqls, $link);
						mysql_query("SET NAMES UTF8");
						$numrowss = mysql_num_rows($results);
						if($numrowss > 0)
						{
							$number = 1;
							while ($arr_stu = mysql_fetch_array($results, MYSQL_ASSOC))
							{
								$name = $arr_stu['name'];
								$student_code = $arr_stu['student_code'];
								$student_id = $arr_stu['id_student'];
								echo '<tr>';
								echo '<td>'.$number.'</td>';
								//echo '<td>'.$name.'</td>';
								
								$sqle = "SELECT * FROM excercise  WHERE status=1";
								$resulte = mysql_query($sqle, $link);
								mysql_query("SET NAMES UTF8");
								$numrows = mysql_num_rows($resulte);
								if($numrows > 0)
								{
									while ($arr = mysql_fetch_array($resulte))
									{
										$id_excercise = $arr['id_excercise'];
										echo '<td>'.get_score_by_excercise_and_student_id($student_id,$id_excercise,1).'</td>';
										echo '<td>'.get_score_by_excercise_and_student_id($student_id,$id_excercise,2).'</td>';
									}
								}
								echo '</tr>';
								$number++;
							}
						}
						echo "</tbody>"; 
					}	
					?>
		</table>
			
      
            </div>
        </div>
      </div>
      <footer>
        <div class="row">
          <div class="col-lg-12">
            <ul class="list-unstyled">
              <li class="pull-right"><a href="#top">Back to top</a></li>
            </ul>
          </div>
        </div>
      </footer>
    </div>
  </body>
</html>
